home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / NOPAUSE.ZIP / NOPAUSE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-26  |  1.9 KB  |  84 lines

  1. /* NOPAUSE.CPP - Disable Pause.
  2.    (C) Copyright 1991
  3.    By Thomas Astin  CIS: 73407,3427  Prodigy: RNVN08A
  4.    All rights reserved. */
  5.  
  6. /* Disable pause by intercepting interrupt 9 and blocking pause scan codes.*/
  7.  
  8. /* NOTE: This program worked fine on the machine upon which it was
  9.          developed and tested.  Use at your own risk. The author is
  10.          not responsible for any damage, system failure, or the like
  11.          as a result of executing this code.
  12.  
  13.          Compiles under Borland C++.  Code may require modifications for
  14.          use with other compilers.
  15. */
  16.  
  17.  
  18. #include <dos.h>
  19. #include <stdio.h>
  20.  
  21. /* Protos */
  22. void interrupt NewInt9(...);
  23. void ExitFunc(void);
  24.  
  25. /* exit func in case ^C */
  26. #pragma exit ExitFunc
  27.  
  28. /* Defines */
  29. #define KbdIn  0x60
  30. #define KbdCtl 0x61
  31. #define MaxChkIdx 3
  32.  
  33. /* Globals */
  34. unsigned char ChkArray[MaxChkIdx] = {0xE1,0x1D,0x45};
  35. unsigned char ChkIdx=0;
  36. unsigned char CurScan=0;
  37. void interrupt (*OldInt9)(...)=NULL;
  38.  
  39. main(void)
  40. {
  41.     int num=0;
  42.  
  43.     OldInt9=getvect(9);                            // grab keyboard int 9
  44.     setvect(9,NewInt9);                            // point to ours
  45.  
  46.     while (CurScan!=0x01)                        // show off
  47.         printf("Try to pause me %d\r",num++);
  48.     return(0);
  49. }
  50.  
  51. void interrupt NewInt9(...)                        // int 9 handler
  52. {
  53.     CurScan=inportb(KbdIn);                        // get scan code
  54.     if (CurScan==ChkArray[ChkIdx++]) {            // check scan code array
  55.         if (ChkIdx>=MaxChkIdx) {                // last match?
  56.             ChkIdx=0;                            // get ready for next time
  57.  
  58.             asm     in         al,KbdCtl            // restore keyboard
  59.             asm     mov     ah,al
  60.             asm     or        al,80h
  61.             asm     jmp     temp1
  62.                 temp1:
  63.             asm     out     KbdCtl,al
  64.             asm     xchg    ah,al
  65.             asm     jmp     temp2
  66.                 temp2:
  67.             asm     out     KbdCtl,al
  68.             asm     mov     al,20h                // Issue EOI
  69.             asm     out     20h,al
  70.  
  71.             return;
  72.         }
  73.     }
  74.     else
  75.         ChkIdx=0;  // start over
  76.  
  77.     OldInt9();        // call original int 9
  78. }
  79.  
  80. void ExitFunc(void)
  81. {
  82.     if (OldInt9!=NULL)
  83.         setvect(9,OldInt9);                            // restore int 9
  84. }